package net.huashitong.scheduling.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import net.huashitong.scheduling.entity.Accounting;
import net.huashitong.scheduling.entity.ProjectRecommendation;
import net.huashitong.scheduling.entity.ProjectReserve;
import net.huashitong.scheduling.filter.ProjectReserveFilter;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class ProjectRecommendationDao extends StringDao<ProjectRecommendation> {

    public List<ProjectRecommendation> queryByCategory(String category){
        GenericQuery query = createQuery("obj");
        query.append(" and obj.category = :category").setParam("category",category);
        return query.listResult();
    }

    public List<ProjectRecommendation> queryByCategoryDetail(String categoryDetail){
        GenericQuery query = createQuery("obj");
        query.append(" and obj.categoryDetail = :categoryDetail").setParam("categoryDetail",categoryDetail);
        return query.listResult();

    }

    public List<ProjectRecommendation> queryByMonthAndYearAndCategoryDetail(ProjectReserveFilter filter){
        GenericQuery query = createQuery("obj");
        query.append(" and obj.month = :month").setParam("month",filter.getMonth());
        query.append(" and obj.year = :year").setParam("year",filter.getYear());
        query.append(" and obj.categoryDetail = :categoryDetail").setParam("categoryDetail",filter.getCategoryDetail());
        return query.listResult();
    }

    public List<ProjectRecommendation> queryByMonthAndYear(String month,String year){
        GenericQuery query = createQuery("obj");
        query.append(" and obj.month = :month").setParam("month",month);
        query.append(" and obj.year = :year").setParam("year",year);
        return query.listResult();
    }


}
